package com.javaee.term.model;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.javaee.term.Enums.ContactStatusEnum;
import com.javaee.term.Enums.PrintStatusEnum;
import com.javaee.term.utils.EnumUtil;
import com.javaee.term.utils.serializer.Date2LongSerializer;
import org.hibernate.annotations.DynamicUpdate;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;
import javax.persistence.*;
@DynamicUpdate
public class Contact {
    /**
     * 主键
     */
    @Id
    @Column(name = "contact_id")
    private String contactId;

    @Column(name = "customer_id")
    private String customerId;

    @Column(name = "man_id")
    private Integer manId;

    /**
     * 合同履行状态, 默认为未履行
     */
    @Column(name = "performance_status")
    private Integer performanceStatus= ContactStatusEnum.NOTFULFILLED.getCode();

    /**
     * 总价格
     */
    @Column(name = "contact_money")
    private BigDecimal contactMoney;

    /**
     * 创建时间
     */
    @JsonSerialize(using = Date2LongSerializer.class)
    @Column(name = "create_time")
    private Date createTime;

    /**
     * 修改时间
     */
    @Column(name = "update_time")
    private Date updateTime;

    /**
     * 获取主键
     *
     * @return contact_id - 主键
     */
    public String getContactId() {
        return contactId;
    }

    /**
     * 设置主键
     *
     * @param contactId 主键
     */
    public void setContactId(String contactId) {
        this.contactId = contactId == null ? null : contactId.trim();
    }

    /**
     * @return customer_id
     */
    public String getCustomerId() {
        return customerId;
    }

    /**
     * @param customerId
     */
    public void setCustomerId(String customerId) {
        this.customerId = customerId == null ? null : customerId.trim();
    }

    /**
     * @return man_id
     */
    public Integer getManId() {
        return manId;
    }

    /**
     * @param manId
     */
    public void setManId(Integer manId) {
        this.manId = manId;
    }

    /**
     * 获取合同履行状态, 默认为未履行
     *
     * @return performance_status - 合同履行状态, 默认为未履行
     */
    public Integer getPerformanceStatus() {
        return performanceStatus;
    }

    /**
     * 设置合同履行状态, 默认为未履行
     *
     * @param performanceStatus 合同履行状态, 默认为未履行
     */
    public void setPerformanceStatus(Integer performanceStatus) {
        this.performanceStatus = performanceStatus;
    }

    /**
     * 获取总价格
     *
     * @return contact_money - 总价格
     */
    public BigDecimal getContactMoney() {
        return contactMoney;
    }

    /**
     * 设置总价格
     *
     * @param contactMoney 总价格
     */
    public void setContactMoney(BigDecimal contactMoney) {
        this.contactMoney = contactMoney;
    }

    /**
     * 获取创建时间
     *
     * @return create_time - 创建时间
     */
    public Date getCreateTime() {
        return createTime;
    }

    /**
     * 设置创建时间
     *
     * @param createTime 创建时间
     */
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    /**
     * 获取修改时间
     *
     * @return update_time - 修改时间
     */
    public Date getUpdateTime() {
        return updateTime;
    }

    /**
     * 设置修改时间
     *
     * @param updateTime 修改时间
     */
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public  String getStringUpdate(){
        DateFormat df5_1 = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
        return  df5_1.format(updateTime);
    }
    @JsonIgnore
    public  String getStringCreate(){
        DateFormat df5_1 = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
        return  df5_1.format(createTime);
    }

    @JsonIgnore
    public ContactStatusEnum getContactStatusEnum() {
        return EnumUtil.getByCode(performanceStatus, ContactStatusEnum.class);
    }

}